<template>
    <!-- 依赖iview栅格布局与animate.css -->
    <div class="bg" v-show="show">
        <transition 
            enter-active-class="animated fadeInUp">
            <div class="popups" v-show="popupsShow">
                <Row class="top">
                    <Col class="top-left" span=4 offset=1 @click.native="close">
                        <slot name="top-left">
                            <Icon type="close" size="18"></Icon>
                        </slot>
                    </Col>
                    <Col span=14 class="top-title">
                        <slot name="title">
                            标题
                        </slot>
                    </Col>
                    <Col span=3 offset=2 class="top-right" @click.native="complate">
                        <slot name="top-right">
                            确定
                        </slot>
                    </Col>
                </Row>
                <div>
                    <slot>内容区域</slot>
                </div>
            </div>
        </transition>
    </div>
</template>

<script>
export default {
    props: ['show'],
    data() {
        return {
            popupsShow: this.show
        }
    },
    watch: {
        show() {
            setTimeout(() => {
                this.popupsShow = this.show
            }, 0)
        }
    },
    methods: {
        close() {
            this.$emit('close')
        },
        complate() {
            this.$emit('complate')
        }
    }
}
</script>

<style lang="less" scoped>
    .bg{
        position: absolute;
        top: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0,0,0,.5); 
        z-index: 11;
        .popups{
            position: fixed;
            bottom: 0;
            width: 100vw;
            height: 50vh;
            background-color: #fff;
            animation-duration: .3s;
            .top{
                height: 54px;
                line-height: 54px;
                color: #3399ff;
                border-bottom: 1px solid #eaeaea;
                .top-left{
                    text-align: left;
                }
                .top-title{
                    color: #000;
                    font-size: 18px;
                    text-align: center;
                }
                .top-right{
                    font-size: 16px;
                    font-weight: bolder;
                }
            }
        }
    }
</style>
